<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 4.2.1">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"www.lixiaofei.cn","root":"/","scheme":"Mist","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":true,"storage":true,"lazyload":true,"nav":{"valine":{"order":-1}}},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}};
  </script>

  <meta name="description" content="静态网站生成器 参考代码">
<meta property="og:type" content="article">
<meta property="og:title" content="轻量级Django 读书笔记-第三章">
<meta property="og:url" content="http://www.lixiaofei.cn/2018-06-15-django3/index.html">
<meta property="og:site_name" content="管窥程序">
<meta property="og:description" content="静态网站生成器 参考代码">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2018-06-15T00:36:09.000Z">
<meta property="article:modified_time" content="2020-07-24T07:59:55.048Z">
<meta property="article:author" content="太阳雪">
<meta property="article:tag" content="Django">
<meta property="article:tag" content="Python">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="http://www.lixiaofei.cn/2018-06-15-django3/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>轻量级Django 读书笔记-第三章 | 管窥程序</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">管窥程序</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">Today is a gift</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a>

  </li>
  </ul>
</nav>




</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>
  <div class="reading-progress-bar"></div>

  <a href="https://github.com/alisx" class="github-corner" title="Follow me on GitHub" aria-label="Follow me on GitHub" rel="noopener" target="_blank"><svg width="80" height="80" viewBox="0 0 250 250" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://www.lixiaofei.cn/2018-06-15-django3/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.png">
      <meta itemprop="name" content="太阳雪">
      <meta itemprop="description" content="总结 技术 思考 想法">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="管窥程序">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          轻量级Django 读书笔记-第三章
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2018-06-15 08:36:09" itemprop="dateCreated datePublished" datetime="2018-06-15T08:36:09+08:00">2018-06-15</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2020-07-24 15:59:55" itemprop="dateModified" datetime="2020-07-24T15:59:55+08:00">2020-07-24</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Readingnote/" itemprop="url" rel="index"><span itemprop="name">Readingnote</span></a>
                </span>
            </span>

          
            <span id="/2018-06-15-django3/" class="post-meta-item leancloud_visitors" data-flag-title="轻量级Django 读书笔记-第三章" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="far fa-comment"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2018-06-15-django3/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2018-06-15-django3/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h1>静态网站生成器</h1>
<p><a href="https://github.com/alisx/lightdjango_practice/tree/master/Chapter%203" target="_blank" rel="noopener">参考代码</a></p>
<a id="more"></a>
<h2 id="概要">概要</h2>
<ul>
<li>什么是静态网站生成器静态网站生成器，就是将原来的网站（可能是动态或者静态的）的每一页面转换为html文件的工具</li>
<li>有什么好处
<ol>
<li>方便部署，不需要复杂的Web服务器，只需要能提供静态内容的Web服务器就行</li>
<li>便于搜索引擎爬虫抓取</li>
<li>可以作为dome生成工具，快速展示自己的设计和想法</li>
</ol>
</li>
<li>用什么做
<ul>
<li>有很多静态网站生成器工具，我用的是<a href="https://hexo.io/zh-cn/" target="_blank" rel="noopener">Hexo</a></li>
<li>Django可以轻松的作为静态网站生成器使用</li>
</ul>
</li>
<li>怎么做
<ol>
<li>借助第二章内容，创建一个简易的Django项目</li>
<li>规划网站的基本机构，抽象为公共页，框架页，和内容页三部分</li>
<li>使用Django模板引擎，和视图将内容页展示为正常的网页</li>
<li>自定义命令执行网站静态话过程</li>
<li>利用Django测试客户端逐个访问内容页，将返回的内容作为html件输出到定义好的静态目录</li>
<li>进一步对引用的CSS和JS文件进行压缩处理</li>
<li>争对单个页面生成的优化</li>
<li>利用python的 http.server 作为Web服务器，启动静态网站</li>
</ol>
</li>
</ul>
<h2 id="详细">详细</h2>
<h3 id="网站规划">网站规划</h3>
<ul>
<li><strong>基础页</strong><br>
指的是网站中每个页面中固定的部分，这些部分可能是样式不变，或者文字不变等，但总有些共通之处，例如每个页面上要显示的Banner，和Footer，这些内容和结构相对固定，另外就是页面的标题，以及针对SEO优化的信息，都是相对固定的，或者说变化是有规律的，将这些部分抽取出来，作为一个基础模板页，其他页面都是从这个页面上生成或者继承的，这里会用到模板引擎，参考<a href="###Django%E6%A8%A1%E6%9D%BF%E5%BC%95%E6%93%8E">Django模板引擎</a></li>
<li><strong>页面框架</strong><br>
有了基础页，可以不用有框架页了，但是为了让代码更灵活，以及解耦和需要一个页面框架来提供内容的组织和一些个性化的设置。<br>
页面框架的继承自<strong>基础页</strong>，并对基础页中定义的可重写部分做了个性化的设置，最后将内容页的内容作为模板变量替换到基础页上，从而形成完整的网页</li>
<li><strong>内容页</strong><br>
有了上面的基础，内容也只负责具体的内容，也就是只写最终网页上主体内容的部分，不用关注公共的部分，最后，内容页的文件名将作为内容页的唯一标识，也可以理解成最终作为URL的一部分，以及作为页面个性化的一部分，比如每个页的标题</li>
</ul>
<h3 id="Django模板引擎">Django模板引擎</h3>
<ul>
<li>Django有很强的的引擎功能，使用时需要在配置中设置 如下  <figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">TEMPLATES=(</span><br><span class="line">    &#123;</span><br><span class="line">        <span class="string">'BACKEND'</span>: <span class="string">'django.template.backends.django.DjangoTemplates'</span>,  <span class="comment"># 使用的模板引擎</span></span><br><span class="line">        <span class="string">'DIRS'</span>: [],  <span class="comment"># 设置Django搜索模板的路径</span></span><br><span class="line">        <span class="string">'APP_DIRS'</span>: <span class="literal">True</span>  <span class="comment"># 为True表示 在项目所在文件家的templates查找模板</span></span><br><span class="line">    &#125;,</span><br><span class="line">)</span><br></pre></td></tr></table></figure>
</li>
<li>渲染模板
<ol>
<li>引用 <code>from django.shortcuts import render</code></li>
<li>渲染 <code>render(request, 'page.html', context)</code><br>
<code>request</code>为http请求，<code>page.html</code>为模板文件，<code>context</code>为模板上下文变量<br>
示例：</li>
</ol>
  <figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">context = &#123;</span><br><span class="line">    <span class="string">'slug'</span>: slug,</span><br><span class="line">    <span class="string">'page'</span>: page,</span><br><span class="line">&#125;</span><br><span class="line">render(request, <span class="string">'page.html'</span>, context)</span><br></pre></td></tr></table></figure>
</li>
<li>模板语法</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">| 场景 |语法|示例|</span><br><span class="line">|:---|:---|:---|</span><br><span class="line">|上下文|&#96;&#123;&#123;  &#125;&#125;&#96;|&#96;&#123;&#123; slug &#125;&#125;&#96;，获取上下文变量中的slug属性，和在python中使用一样|</span><br><span class="line">|系统设置和方法|&#96;&#96;&#96;&#123;% %&#125;&#96;&#96;&#96;|&#96;&#96;&#96;&#123;% load staticfiles %&#125;&#96;&#96;&#96; 为引入&#96;&#96;&#96;static&#96;&#96;&#96;系统方法|</span><br></pre></td></tr></table></figure>
<ul>
<li>常用的系统设置和方法</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">1. &#96;&#96;&#123;% load staticfiles %&#125;&#96;&#96;: 引入 &#96;static&#96;方法，可以为模板的CSS和JS文件引入提供方便</span><br><span class="line">2. &#96;&#96;&#123;% static %&#125;&#96;&#96;: 计算一个引用文件的网站相对路径 例如 &#96;&#123;% static &#39;css&#x2F;site.css&#39; %&#125;&#96; </span><br><span class="line">3. &#96;&#96;&#123;% include temp %&#125;&#96;&#96;: 包含一个模板变量（注意不是模板字符串，而是一个模板实体），即将其他模板内容合并在这里</span><br><span class="line">4. &#96;&#96;&#123;% extends &#39;base.html&#39; %&#125;&#96;&#96;: 模板的继承，表示当前模板继承自&#96;base.html&#96;模板</span><br><span class="line">5. &#96;&#96;&#123;% block blogtag %&#125; ... &#123;% endblock %&#125;&#96;&#96;: 在父模板中表示可以被子模版重写的部分，在子模版中表示需要重写父模板的部分 </span><br><span class="line">6. &#96;&#96;&#123;% if slug &#x3D;&#x3D; &#39;index&#39; %&#125; ... &#123;% endif %&#125;&#96;&#96;: 表示判断,通过判断，就会显示在if范围内的内容</span><br><span class="line">7. &#96;&#96;&#123;% url ... %&#125;&#96;&#96;:生成一个url，与&#96;&#96;static&#96;&#96;不同的是需要为他指定一个&#96;&#96;view&#96;&#96;,然后写上&#96;&#96;view&#96;&#96;需要的参数 例如 &#96;&#96;&#123;% url &#39;page&#39; &#39;index&#39; %&#125;&#96;&#96;,表示用&#96;view page&#96;来生成url，且给定参数 &#96;index&#96;</span><br></pre></td></tr></table></figure>
<ul>
<li>
<p>继承<br>
先看代码示例:<br>
<code>base.html</code></p>
  <figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">&#123;% load staticfiles %&#125;</span><br><span class="line">&lt;!DOCTYPE html&gt;</span><br><span class="line">&lt;html lang=<span class="string">"en"</span>&gt;</span><br><span class="line">&lt;head&gt;</span><br><span class="line">    ...</span><br><span class="line">    &lt;title&gt;&#123;% block title %&#125;Rapid Prototypes&#123;% endblock %&#125;&lt;/title&gt;</span><br><span class="line">    &lt;link rel=<span class="string">"stylesheet"</span> href=<span class="string">"&#123;% static 'css/bootstrap.min.css'%&#125;"</span>&gt;</span><br><span class="line">    ...</span><br><span class="line">&lt;/head&gt;</span><br><span class="line">&lt;body id=<span class="string">"&#123;% block body-id %&#125;body&#123;% endblock %&#125;"</span>&gt;</span><br><span class="line">&#123;% block top-nav-wrapper %&#125;</span><br><span class="line">...</span><br><span class="line">&#123;% endblock %&#125;</span><br><span class="line">&#123;% block content %&#125;&#123;% endblock %&#125;</span><br><span class="line">...</span><br></pre></td></tr></table></figure>
<p><code>page.html</code></p>
  <figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">&#123;% extends &quot;base.html&quot; %&#125;</span><br><span class="line">&#123;% block title %&#125;&#123;&#123; block.super&#125;&#125; - &#123;&#123; slug|capfirst &#125;&#125;&#123;% endblock %&#125;</span><br><span class="line">&#123;% block body-id %&#125;&#123;&#123; slug|slugify &#125;&#125;&#123;% endblock %&#125;</span><br><span class="line">&#123;% block content %&#125;</span><br><span class="line">    &#123;% include page %&#125;</span><br><span class="line">&#123;% endblock %&#125;</span><br></pre></td></tr></table></figure>
<ul>
<li>page.html 继承自 base.html</li>
<li>base.html 设置了 <code>title body-id top-nav-wrapper</code> 和 <code>content</code> 作为可重新部分</li>
<li>page.html 重写了 <code>title</code>，但同时调用了父类的 <code>title</code>值，用 <code>block.super</code></li>
<li>page.html 并没有重写 <code>top-nav-wrapper</code>,所以在生成的页面中沿用base.html 中定义的部分</li>
</ul>
</li>
</ul>
<h3 id="遍历所有页面">遍历所有页面</h3>
<ul>
<li>原理是，由于所有的内容也都是定义在pages文件夹下的，而且由于url路由的设置，是将文件名作为url的路径的，所有只要遍历pages下的文件，并且合成响应的url，通过python的测试客户端就可以访问,将返回的结果放在生成文件夹中</li>
<li>步骤
<ol>
<li>处理静态文件,不是直接将文件拷贝过去而是，利用Django内置命令 <code>collectstatic</code><br>
<code>call_command('collectstatic', interactive=False, clear=True, verbosity=0)</code></li>
<li>遍历页面文件夹中的文件,利用Django urls的 <code>reverse</code>（和模板中的url类似）,将指定<code>view</code>的url合成出来</li>
<li>通过测试客户端请求页面,厉害的是，这里并不需要启动服务，测试客户端会自动合成好页面内容</li>
<li>将请求的结果写入到对于内容模板的文件中去</li>
</ol>
</li>
</ul>

    </div>

    
    
    

      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/Django/" rel="tag"># Django</a>
              <a href="/tags/Python/" rel="tag"># Python</a>
          </div>

        

			<div id="wechat_subscriber" style="display: block; padding: 10px 0; margin: 20px auto; width: 100%; text-align: center">
    <img id="wechat_subscriber_qcode" src="/images/wechat-qcode.png" alt="太阳雪 wechat" style="width: 200px; max-width: 100%;"/>
    <div>关注我，获得更多精彩内容</div>
</div>

        
		
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2018-06-05-django2/" rel="prev" title="轻量级Django 读书笔记-第二章">
      <i class="fa fa-chevron-left"></i> 轻量级Django 读书笔记-第二章
    </a></div>
      <div class="post-nav-item">
    <a href="/2019-01-21-spring-boot/" rel="next" title="突破SpringBoot概念">
      突破SpringBoot概念 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          
    <div class="comments" id="valine-comments"></div>

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#"><span class="nav-number">1.</span> <span class="nav-text">静态网站生成器</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#概要"><span class="nav-number">1.1.</span> <span class="nav-text">概要</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#详细"><span class="nav-number">1.2.</span> <span class="nav-text">详细</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#网站规划"><span class="nav-number">1.2.1.</span> <span class="nav-text">网站规划</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Django模板引擎"><span class="nav-number">1.2.2.</span> <span class="nav-text">Django模板引擎</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#遍历所有页面"><span class="nav-number">1.2.3.</span> <span class="nav-text">遍历所有页面</span></a></li></ol></li></ol></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="太阳雪"
      src="/images/avatar.png">
  <p class="site-author-name" itemprop="name">太阳雪</p>
  <div class="site-description" itemprop="description">总结 技术 思考 想法</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">88</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">14</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">47</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2022</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">太阳雪</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://mist.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Mist</a> 强力驱动
  </div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/muse.js"></script>


<script src="/js/next-boot.js"></script>




  
  <script>
    (function(){
      var canonicalURL, curProtocol;
      //Get the <link> tag
      var x=document.getElementsByTagName("link");
		//Find the last canonical URL
		if(x.length > 0){
			for (i=0;i<x.length;i++){
				if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){
					canonicalURL=x[i].href;
				}
			}
		}
    //Get protocol
	    if (!canonicalURL){
	    	curProtocol = window.location.protocol.split(':')[0];
	    }
	    else{
	    	curProtocol = canonicalURL.split(':')[0];
	    }
      //Get current URL if the canonical URL does not exist
	    if (!canonicalURL) canonicalURL = window.location.href;
	    //Assign script content. Replace current URL with the canonical URL
      !function(){var e=/([http|https]:\/\/[a-zA-Z0-9\_\.]+\.baidu\.com)/gi,r=canonicalURL,t=document.referrer;if(!e.test(r)){var n=(String(curProtocol).toLowerCase() === 'https')?"https://sp0.baidu.com/9_Q4simg2RQJ8t7jm9iCKT-xh_/s.gif":"//api.share.baidu.com/s.gif";t?(n+="?r="+encodeURIComponent(document.referrer),r&&(n+="&l="+r)):r&&(n+="?l="+r);var i=new Image;i.src=n}}(window);})();
  </script>















  

  


<script>
NexT.utils.loadComments(document.querySelector('#valine-comments'), () => {
  NexT.utils.getScript('//unpkg.com/valine/dist/Valine.min.js', () => {
    var GUEST = ['nick', 'mail', 'link'];
    var guest = 'nick,mail';
    guest = guest.split(',').filter(item => {
      return GUEST.includes(item);
    });
    new Valine({
      el         : '#valine-comments',
      verify     : false,
      notify     : false,
      appId      : 'teRj7yeJj0xpfGKLJ5uFdbIu-gzGzoHsz',
      appKey     : '3uie0p1nxouCCnkjiXTEBeLd',
      placeholder: "您的关注是我的动力",
      avatar     : 'mm',
      meta       : guest,
      pageSize   : '10' || 10,
      visitor    : true,
      lang       : 'zh-cn' || 'zh-cn',
      path       : location.pathname,
      recordIP   : false,
      serverURLs : ''
    });
  }, window.Valine);
});
</script>

</body>
</html>
